import request from "@/utils/request.js";


/**
 * 获取 PDF 转换后的所有图片页 URL
 * @param {string} filePath - PDF 文件路径
 * @returns {Promise}
 */
export function getPdfImageUrls(filePath) {
    return request({
        url: "/upload/pdfImages",
        method: "get",
        params: {
            filePath
        },
        timeout: 320000,
    });
}













export function previewFile(data) {
    return request({
        url: '/upload/preview', // 修改为完整的 URL
        method: 'post',
        data,
        responseType: 'blob',  // 重要：设置响应类型为blob
        headers: {
            'Accept': 'application/pdf'
        }
    })
}



export function deleteFile(fileId) {
    return request({
        url: `http://localhost:8080/api/files/${fileId}`,
        method: 'delete'
    })
}
export function deletePdfPage(filePath, pageNumber) {
    return request({
        url: 'http://localhost:8080/deletePdfPage',
        method: 'post',
        params: { filePath, pageNumber }
    })
}

// 追加上传文件
export function appendFile(formData) {

    return request({
        url: 'http://localhost:8080/upload/appendPdf',
        method: 'post',
        data: formData,
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    })
}
